﻿<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="mtrUserControl.ascx.cs" Inherits="UCWebpart.Admin.mtrUserControl" %>
 <script type="text/javascript" src="../JS/jquery-1.7.1.js"></script>
<br/>
<style type="text/css">
        table
        {
            border: 1px solid #B1CDE3;
            padding:0;
            margin:0 auto;
            border-collapse: collapse;
        }
        td
        {
            border: 1px solid #B1CDE3;
            background: #fff;
            font-size:12px;
            color: #4f6b72;
            text-align:center;
 
        }
        </style>

<table style="float:left"><tr>
    <td style="width:200px">
        <asp:DropDownList ID="normalManage" runat="server" AutoPostBack="True" OnSelectedIndexChanged="normalManage_SelectedIndexChanged"></asp:DropDownList>
    </td>
    <td>
         <div id="left0" style="overflow-y:scroll;height:260px;width:700px; text-align: left;">
             <asp:GridView ID="GridView2" runat="server" CellPadding="4" ForeColor="#333333" GridLines="None">
                 <AlternatingRowStyle BackColor="White" />
                 <EditRowStyle BackColor="#2461BF" />
                 <FooterStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
                 <HeaderStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
                 <PagerStyle BackColor="#2461BF" ForeColor="White" HorizontalAlign="Center" />
                 <RowStyle BackColor="#EFF3FB" />
                 <SelectedRowStyle BackColor="#D1DDF1" Font-Bold="True" ForeColor="#333333" />
                 <SortedAscendingCellStyle BackColor="#F5F7FB" />
                 <SortedAscendingHeaderStyle BackColor="#6D95E1" />
                 <SortedDescendingCellStyle BackColor="#E9EBEF" />
                 <SortedDescendingHeaderStyle BackColor="#4870BE" />

             </asp:GridView>
         </div>
    </td>

</tr>
    <tr><td>
        <div runat ="server" id="mtrUser">
<p>
    <label for="AdminName">名&nbsp;称：</label> 
    <asp:TextBox ID="AdminName" runat="server" Width="130px"></asp:TextBox>
    <br />
</p>
<p>
    <label for="venueType">类&nbsp;型：</label> 
    <asp:DropDownList ID="venueType" runat="server" Width="130px"> 
    </asp:DropDownList>
</p>

<p>
    <label>级&nbsp;别：</label>
    <asp:DropDownList ID="adminLevel" runat="server" Enabled="False" Width="130px">
        <asp:ListItem Value="1">普通管理员</asp:ListItem>
        <asp:ListItem Value="2">高级管理员</asp:ListItem>
    </asp:DropDownList>
    </p>

<asp:Button ID="Button1" runat="server" Text="添加管理员" OnClick="Button1_Click1" />
 </div>   
        </td><td>
<div  style="overflow-y:scroll;height:200px; text-align: left;">
<asp:GridView ID="GridView1" runat="server" AllowPaging="True" AllowSorting="True" AutoGenerateColumns="False" DataKeyNames="adminId" DataSourceID="SqlDataSource1" CellPadding="4" ForeColor="#333333" GridLines="None" OnRowDataBound="GridView1_RowDataBound" OnRowDeleting="GridView1_RowDeleting">
    <AlternatingRowStyle BackColor="White" />
    <Columns>
        <asp:CommandField ShowDeleteButton="True" ShowEditButton="True" />
        <asp:BoundField DataField="adminId" HeaderText="adminId" InsertVisible="False" ReadOnly="True" SortExpression="adminId" Visible="False" />
        <asp:BoundField DataField="adminName" HeaderText="名称" SortExpression="adminName" />
        <asp:TemplateField HeaderText="类型" SortExpression="VenueType">
            <EditItemTemplate>
                <asp:TextBox ID="tbType" runat="server" Text='<%# Bind("VenueType") %>' Height="16px" Width="61px" Visible="False"></asp:TextBox>
                <asp:DropDownList ID="ddlVenueType" runat="server" AutoPostBack="True" OnSelectedIndexChanged="ddlVenueType_SelectedIndexChanged">
                </asp:DropDownList>
            </EditItemTemplate>
            <ItemTemplate>
                <asp:Label ID="Label1" runat="server" Text='<%# Bind("VenueType") %>'></asp:Label>
            </ItemTemplate>
        </asp:TemplateField>
        <asp:TemplateField HeaderText="级别" SortExpression="adminLevel">
            <EditItemTemplate>
                <asp:TextBox ID="TBlevel" runat="server" Text='<%# Bind("adminLevel") %>' Height="16px" Width="56px" Visible="False"></asp:TextBox>
                <asp:DropDownList ID="DDLlevel" runat="server" AutoPostBack="True" OnSelectedIndexChanged="DDLlevel_SelectedIndexChanged">
                     <asp:ListItem Value="1">普通管理员</asp:ListItem>
                     <asp:ListItem Value="2">高级管理员</asp:ListItem>
                </asp:DropDownList>
            </EditItemTemplate>
            <ItemTemplate>
                <asp:Label ID="Label2" runat="server" Text='<%# Bind("adminLevel") %>'></asp:Label>
            </ItemTemplate>
        </asp:TemplateField>
    </Columns>
    <EditRowStyle BackColor="#2461BF" />
    <FooterStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
    <HeaderStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
    <PagerStyle BackColor="#2461BF" ForeColor="White" HorizontalAlign="Center" />
    <RowStyle BackColor="#EFF3FB" />
    <SelectedRowStyle BackColor="#D1DDF1" Font-Bold="True" ForeColor="#333333" />
    <SortedAscendingCellStyle BackColor="#F5F7FB" />
    <SortedAscendingHeaderStyle BackColor="#6D95E1" />
    <SortedDescendingCellStyle BackColor="#E9EBEF" />
    <SortedDescendingHeaderStyle BackColor="#4870BE" />
</asp:GridView>
    </div>
             </td></tr>
<tr><td>
    <asp:Label ID="Label3" runat="server" Text="Label"></asp:Label>
    </td><td></td></tr>
</table>

<asp:SqlDataSource ID="SqlDataSource1" runat="server" 
    ConnectionString="<%$ ConnectionStrings:meetingroomManagementConnectionString %>"
    DeleteCommand="UPDATE [MTR_bas_Admin] SET [Available] = 0 WHERE [adminId] = @adminId" 
    InsertCommand="INSERT INTO [MTR_bas_Admin] ([adminName], [adminLevel], [VenueType], [Available],) VALUES (@adminName, @adminLevel, @VenueType, @Available)" 
    SelectCommand="SELECT adminId,adminName,VenueType,adminLevel FROM MTR_bas_Admin (nolock) where Available=1 and adminLevel in (1,2) order by adminId desc" 
    UpdateCommand="UPDATE [MTR_bas_Admin] SET [adminName] = @adminName, [adminLevel] = @adminLevel, [VenueType] = @VenueType, [Available] = 1 WHERE [adminId] = @adminId">
    <DeleteParameters>
        <asp:Parameter Name="adminId" />
    </DeleteParameters>
    <InsertParameters>
        <asp:Parameter Name="adminName" Type="String" />
        <asp:Parameter Name="adminLevel" Type="Int32" />
        <asp:Parameter Name="VenueType" />
        <asp:Parameter Name="Available" Type="Boolean" />
    </InsertParameters>
    <UpdateParameters>
        <asp:Parameter Name="adminName" Type="String" />
        <asp:Parameter Name="adminLevel" Type="Int32" />
        <asp:Parameter Name="VenueType" />
        <asp:Parameter Name="adminId" Type="Int32" />
    </UpdateParameters>
</asp:SqlDataSource>



